{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Parameter Heatmap\n",
    "==========\n",
    "\n",
    "This tutorial will show how to optimize strategies with multiple parameters and how to examine and reason about optimization results.\n",
    "It is assumed you're already familiar with\n",
    "[basic _backtesting.py_ usage](https://kernc.github.io/backtesting.py/doc/examples/Quick Start User Guide.html).\n",
    "\n",
    "First, let's again import our helper moving average function.\n",
    "In practice, one can use functions from any indicator library, such as\n",
    "[TA-Lib](https://github.com/mrjbq7/ta-lib),\n",
    "[Tulipy](https://tulipindicators.org),\n",
    "PyAlgoTrade, ..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"1001\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "  var JS_MIME_TYPE = 'application/javascript';\n",
       "  var HTML_MIME_TYPE = 'text/html';\n",
       "  var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
       "  var CLASS_NAME = 'output_bokeh rendered_html';\n",
       "\n",
       "  /**\n",
       "   * Render data to the DOM node\n",
       "   */\n",
       "  function render(props, node) {\n",
       "    var script = document.createElement(\"script\");\n",
       "    node.appendChild(script);\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when an output is cleared or removed\n",
       "   */\n",
       "  function handleClearOutput(event, handle) {\n",
       "    var cell = handle.cell;\n",
       "\n",
       "    var id = cell.output_area._bokeh_element_id;\n",
       "    var server_id = cell.output_area._bokeh_server_id;\n",
       "    // Clean up Bokeh references\n",
       "    if (id != null && id in Bokeh.index) {\n",
       "      Bokeh.index[id].model.document.clear();\n",
       "      delete Bokeh.index[id];\n",
       "    }\n",
       "\n",
       "    if (server_id !== undefined) {\n",
       "      // Clean up Bokeh references\n",
       "      var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
       "      cell.notebook.kernel.execute(cmd, {\n",
       "        iopub: {\n",
       "          output: function(msg) {\n",
       "            var id = msg.content.text.trim();\n",
       "            if (id in Bokeh.index) {\n",
       "              Bokeh.index[id].model.document.clear();\n",
       "              delete Bokeh.index[id];\n",
       "            }\n",
       "          }\n",
       "        }\n",
       "      });\n",
       "      // Destroy server and session\n",
       "      var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
       "      cell.notebook.kernel.execute(cmd);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when a new output is added\n",
       "   */\n",
       "  function handleAddOutput(event, handle) {\n",
       "    var output_area = handle.output_area;\n",
       "    var output = handle.output;\n",
       "\n",
       "    // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
       "    if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
       "      return\n",
       "    }\n",
       "\n",
       "    var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
       "\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
       "      toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
       "      // store reference to embed id on output_area\n",
       "      output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
       "    }\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
       "      var bk_div = document.createElement(\"div\");\n",
       "      bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
       "      var script_attrs = bk_div.children[0].attributes;\n",
       "      for (var i = 0; i < script_attrs.length; i++) {\n",
       "        toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
       "      }\n",
       "      // store reference to server id on output_area\n",
       "      output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function register_renderer(events, OutputArea) {\n",
       "\n",
       "    function append_mime(data, metadata, element) {\n",
       "      // create a DOM node to render to\n",
       "      var toinsert = this.create_output_subarea(\n",
       "        metadata,\n",
       "        CLASS_NAME,\n",
       "        EXEC_MIME_TYPE\n",
       "      );\n",
       "      this.keyboard_manager.register_events(toinsert);\n",
       "      // Render to node\n",
       "      var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
       "      render(props, toinsert[toinsert.length - 1]);\n",
       "      element.append(toinsert);\n",
       "      return toinsert\n",
       "    }\n",
       "\n",
       "    /* Handle when an output is cleared or removed */\n",
       "    events.on('clear_output.CodeCell', handleClearOutput);\n",
       "    events.on('delete.Cell', handleClearOutput);\n",
       "\n",
       "    /* Handle when a new output is added */\n",
       "    events.on('output_added.OutputArea', handleAddOutput);\n",
       "\n",
       "    /**\n",
       "     * Register the mime type and append_mime function with output_area\n",
       "     */\n",
       "    OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
       "      /* Is output safe? */\n",
       "      safe: true,\n",
       "      /* Index of renderer in `output_area.display_order` */\n",
       "      index: 0\n",
       "    });\n",
       "  }\n",
       "\n",
       "  // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
       "  if (root.Jupyter !== undefined) {\n",
       "    var events = require('base/js/events');\n",
       "    var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
       "\n",
       "    if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
       "      register_renderer(events, OutputArea);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    var el = document.getElementById(\"1001\");\n",
       "    if (el != null) {\n",
       "      el.textContent = \"BokehJS is loading...\";\n",
       "    }\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    }\n",
       "    finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        root._bokeh_is_loading--;\n",
       "        if (root._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"1001\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.3.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.3.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.3.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.3.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.3.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.3.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.3.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.3.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.3.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.3.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i].call(root, root.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ],
      "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n  function now() {\n    return new Date();\n  }\n\n  var force = true;\n\n  if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n    root._bokeh_onload_callbacks = [];\n    root._bokeh_is_loading = undefined;\n  }\n\n  \n\n  \n  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n    root._bokeh_timeout = Date.now() + 5000;\n    root._bokeh_failed_load = false;\n  }\n\n  var NB_LOAD_WARNING = {'data': {'text/html':\n     \"<div style='background-color: #fdd'>\\n\"+\n     \"<p>\\n\"+\n     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n     \"</p>\\n\"+\n     \"<ul>\\n\"+\n     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n     \"</ul>\\n\"+\n     \"<code>\\n\"+\n     \"from bokeh.resources import INLINE\\n\"+\n     \"output_notebook(resources=INLINE)\\n\"+\n     \"</code>\\n\"+\n     \"</div>\"}};\n\n  function display_loaded() {\n    var el = document.getElementById(\"1001\");\n    if (el != null) {\n      el.textContent = \"BokehJS is loading...\";\n    }\n    if (root.Bokeh !== undefined) {\n      if (el != null) {\n        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n      }\n    } else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(display_loaded, 100)\n    }\n  }\n\n\n  function run_callbacks() {\n    try {\n      root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n    }\n    finally {\n      delete root._bokeh_onload_callbacks\n    }\n    console.info(\"Bokeh: all callbacks have finished\");\n  }\n\n  function load_libs(js_urls, callback) {\n    root._bokeh_onload_callbacks.push(callback);\n    if (root._bokeh_is_loading > 0) {\n      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n      return null;\n    }\n    if (js_urls == null || js_urls.length === 0) {\n      run_callbacks();\n      return null;\n    }\n    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n    root._bokeh_is_loading = js_urls.length;\n    for (var i = 0; i < js_urls.length; i++) {\n      var url = js_urls[i];\n      var s = document.createElement('script');\n      s.src = url;\n      s.async = false;\n      s.onreadystatechange = s.onload = function() {\n        root._bokeh_is_loading--;\n        if (root._bokeh_is_loading === 0) {\n          console.log(\"Bokeh: all BokehJS libraries loaded\");\n          run_callbacks()\n        }\n      };\n      s.onerror = function() {\n        console.warn(\"failed to load library \" + url);\n      };\n      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n      document.getElementsByTagName(\"head\")[0].appendChild(s);\n    }\n  };var element = document.getElementById(\"1001\");\n  if (element == null) {\n    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n    return false;\n  }\n\n  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.3.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.3.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.3.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.3.min.js\"];\n\n  var inline_js = [\n    function(Bokeh) {\n      Bokeh.set_log_level(\"info\");\n    },\n    \n    function(Bokeh) {\n      \n    },\n    function(Bokeh) {\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.3.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.3.min.css\");\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.3.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.3.min.css\");\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.3.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.3.min.css\");\n    }\n  ];\n\n  function run_inline_js() {\n    \n    if ((root.Bokeh !== undefined) || (force === true)) {\n      for (var i = 0; i < inline_js.length; i++) {\n        inline_js[i].call(root, root.Bokeh);\n      }if (force === true) {\n        display_loaded();\n      }} else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(run_inline_js, 100);\n    } else if (!root._bokeh_failed_load) {\n      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n      root._bokeh_failed_load = true;\n    } else if (force !== true) {\n      var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n    }\n\n  }\n\n  if (root._bokeh_is_loading === 0) {\n    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n    run_inline_js();\n  } else {\n    load_libs(js_urls, function() {\n      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n      run_inline_js();\n    });\n  }\n}(window));"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from backtesting.test import SMA"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Our strategy will be a similar moving average cross-over strategy to the one in\n",
    "[Quick Start User Guide](https://kernc.github.io/backtesting.py/doc/examples/Quick Start User Guide.html),\n",
    "but we will use four moving averages in total:\n",
    "two moving averages whose relationship determines a general trend\n",
    "(we only trade long when the shorter MA is above the longer one, and vice versa),\n",
    "and two moving averages whose cross-over with Close prices determine the signal to enter or exit the position."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from backtesting import Strategy\n",
    "from backtesting.lib import crossover\n",
    "\n",
    "\n",
    "class Sma4Cross(Strategy):\n",
    "    n1 = 50\n",
    "    n2 = 100\n",
    "    n_enter = 20\n",
    "    n_exit = 10\n",
    "    \n",
    "    def init(self):\n",
    "        self.sma1 = self.I(SMA, self.data.Close, self.n1)\n",
    "        self.sma2 = self.I(SMA, self.data.Close, self.n2)\n",
    "        self.sma_enter = self.I(SMA, self.data.Close, self.n_enter)\n",
    "        self.sma_exit = self.I(SMA, self.data.Close, self.n_exit)\n",
    "        \n",
    "    def next(self):\n",
    "        \n",
    "        if not self.position:\n",
    "            \n",
    "            # On upwards trend, if price closes above\n",
    "            # \"entry\" MA, go long\n",
    "            \n",
    "            # Here, even though the operands are arrays, this\n",
    "            # works by implicitly comparing the two last values\n",
    "            if self.sma1 > self.sma2:\n",
    "                if crossover(self.data.Close, self.sma_enter):\n",
    "                    self.buy()\n",
    "                    \n",
    "            # On downwards trend, if price closes below\n",
    "            # \"entry\" MA, go short\n",
    "            \n",
    "            else:\n",
    "                if crossover(self.sma_enter, self.data.Close):\n",
    "                    self.sell()\n",
    "        \n",
    "        # But if we already hold a position and the price\n",
    "        # closes back below (above) \"exit\" MA, close the position\n",
    "        \n",
    "        else:\n",
    "            if (self.position.is_long and\n",
    "                crossover(self.sma_exit, self.data.Close)\n",
    "                or\n",
    "                self.position.is_short and\n",
    "                crossover(self.data.Close, self.sma_exit)):\n",
    "                \n",
    "                self.position.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It's not a robust strategy, but we can optimize it. Let's optimize our strategy on Google stock data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 585 ms, sys: 102 ms, total: 687 ms\n",
      "Wall time: 11.7 s\n"
     ]
    }
   ],
   "source": [
    "%%time \n",
    "\n",
    "from backtesting import Backtest\n",
    "from backtesting.test import GOOG\n",
    "\n",
    "\n",
    "backtest = Backtest(GOOG, Sma4Cross, commission=.002)\n",
    "\n",
    "stats, heatmap = backtest.optimize(\n",
    "    n1=range(10, 110, 10),\n",
    "    n2=range(20, 210, 20),\n",
    "    n_enter=range(15, 35, 5),\n",
    "    n_exit=range(10, 25, 5),\n",
    "    constraint=lambda p: p.n_exit < p.n_enter < p.n1 < p.n2,\n",
    "    maximize='Equity Final [$]',\n",
    "    return_heatmap=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice `return_heatmap=True` parameter passed to\n",
    "[`Backtest.optimize()`](https://kernc.github.io/backtesting.py/doc/backtesting/backtesting.html#backtesting.backtesting.Backtest.optimize).\n",
    "It makes the function return a heatmap series along with the usual stats of the best run.\n",
    "`heatmap` is a pandas Series indexed with a MultiIndex, a cartesian product of all permissible parameter values.\n",
    "The series values are from the `maximize=` argument we provided."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "n_exit  n_enter  n2   n1 \n",
       "10      15       40   20      8742.77\n",
       "                      30     10662.30\n",
       "                 60   20     10020.29\n",
       "                      30     11386.84\n",
       "                      40     13179.02\n",
       "                      50      8903.43\n",
       "                 80   20      9877.11\n",
       "                      30      8675.47\n",
       "                      40      9671.30\n",
       "                      50     12621.72\n",
       "                      60     12754.77\n",
       "                      70     15869.19\n",
       "                 100  20     11005.88\n",
       "                      30     10293.02\n",
       "                      40     12212.70\n",
       "                               ...   \n",
       "20      30       160  100     9392.84\n",
       "                 180  40      8080.16\n",
       "                      50      8080.16\n",
       "                      60      8080.16\n",
       "                      70      7727.38\n",
       "                      80      7727.38\n",
       "                      90      7727.38\n",
       "                      100     7727.25\n",
       "                 200  40      7923.41\n",
       "                      50      7923.41\n",
       "                      60      7923.41\n",
       "                      70      7222.44\n",
       "                      80      7863.62\n",
       "                      90      7651.35\n",
       "                      100     7418.69\n",
       "Length: 486, dtype: float64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "heatmap"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This heatmap contains the results of all the runs,\n",
    "making it very easy to obtain parameter combinations for e.g. three best runs:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "n_exit  n1  n_enter  n2 \n",
       "15      40  25       60     21137.84\n",
       "        50  20       120    22012.50\n",
       "        40  20       160    22644.29\n",
       "dtype: float64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "heatmap.sort_values().iloc[-3:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "But people have this enormous faculty of vision, used to make judgements on much larger data sets much faster.\n",
    "Let's plot the whole heatmap by projecting it on two chosen dimensions.\n",
    "Say we're mostly interested in how parameters `n1` and `n2`, on average, affect the outcome."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>n2</th>\n",
       "      <th>40</th>\n",
       "      <th>60</th>\n",
       "      <th>80</th>\n",
       "      <th>100</th>\n",
       "      <th>120</th>\n",
       "      <th>140</th>\n",
       "      <th>160</th>\n",
       "      <th>180</th>\n",
       "      <th>200</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>n1</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>8742.77</td>\n",
       "      <td>10020.29</td>\n",
       "      <td>9877.11</td>\n",
       "      <td>11005.88</td>\n",
       "      <td>12832.05</td>\n",
       "      <td>12115.57</td>\n",
       "      <td>13380.55</td>\n",
       "      <td>9462.92</td>\n",
       "      <td>9993.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>11685.45</td>\n",
       "      <td>11947.24</td>\n",
       "      <td>12507.64</td>\n",
       "      <td>13247.98</td>\n",
       "      <td>12471.19</td>\n",
       "      <td>10955.33</td>\n",
       "      <td>12672.70</td>\n",
       "      <td>11049.38</td>\n",
       "      <td>10599.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>NaN</td>\n",
       "      <td>14522.63</td>\n",
       "      <td>11314.04</td>\n",
       "      <td>8852.70</td>\n",
       "      <td>11252.55</td>\n",
       "      <td>9538.35</td>\n",
       "      <td>12615.52</td>\n",
       "      <td>10804.31</td>\n",
       "      <td>10094.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>NaN</td>\n",
       "      <td>9268.08</td>\n",
       "      <td>10761.43</td>\n",
       "      <td>11780.65</td>\n",
       "      <td>11928.56</td>\n",
       "      <td>10022.42</td>\n",
       "      <td>11639.78</td>\n",
       "      <td>10783.37</td>\n",
       "      <td>9737.71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9901.77</td>\n",
       "      <td>11012.14</td>\n",
       "      <td>9550.52</td>\n",
       "      <td>10839.21</td>\n",
       "      <td>11360.96</td>\n",
       "      <td>10512.38</td>\n",
       "      <td>9653.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11015.24</td>\n",
       "      <td>9408.20</td>\n",
       "      <td>9828.18</td>\n",
       "      <td>10759.51</td>\n",
       "      <td>11366.77</td>\n",
       "      <td>9972.34</td>\n",
       "      <td>8627.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10148.83</td>\n",
       "      <td>10225.92</td>\n",
       "      <td>10272.49</td>\n",
       "      <td>11111.84</td>\n",
       "      <td>10230.37</td>\n",
       "      <td>9560.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11175.10</td>\n",
       "      <td>11240.16</td>\n",
       "      <td>10239.04</td>\n",
       "      <td>11171.33</td>\n",
       "      <td>10561.55</td>\n",
       "      <td>10258.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11954.44</td>\n",
       "      <td>9413.20</td>\n",
       "      <td>11689.47</td>\n",
       "      <td>10094.51</td>\n",
       "      <td>10564.84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "n2        40        60        80        100       120       140       160  \\\n",
       "n1                                                                          \n",
       "20    8742.77  10020.29   9877.11  11005.88  12832.05  12115.57  13380.55   \n",
       "30   11685.45  11947.24  12507.64  13247.98  12471.19  10955.33  12672.70   \n",
       "40        NaN  14522.63  11314.04   8852.70  11252.55   9538.35  12615.52   \n",
       "50        NaN   9268.08  10761.43  11780.65  11928.56  10022.42  11639.78   \n",
       "60        NaN       NaN   9901.77  11012.14   9550.52  10839.21  11360.96   \n",
       "70        NaN       NaN  11015.24   9408.20   9828.18  10759.51  11366.77   \n",
       "80        NaN       NaN       NaN  10148.83  10225.92  10272.49  11111.84   \n",
       "90        NaN       NaN       NaN  11175.10  11240.16  10239.04  11171.33   \n",
       "100       NaN       NaN       NaN       NaN  11954.44   9413.20  11689.47   \n",
       "\n",
       "n2        180       200  \n",
       "n1                       \n",
       "20    9462.92   9993.13  \n",
       "30   11049.38  10599.47  \n",
       "40   10804.31  10094.83  \n",
       "50   10783.37   9737.71  \n",
       "60   10512.38   9653.58  \n",
       "70    9972.34   8627.18  \n",
       "80   10230.37   9560.67  \n",
       "90   10561.55  10258.52  \n",
       "100  10094.51  10564.84  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hm = heatmap.groupby(['n1', 'n2']).mean().unstack()\n",
    "hm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's plot this table using the excellent [_Seaborn_](https://seaborn.pydata.org) package:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x7f15981ab7f0>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEKCAYAAADzQPVvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3XuUnFWZ7/HvLwlkCEhuDBFoNJkx\niKiIwEBmRp0As0JwXAYdIHCcIVwkXnAcPZ7hImeJyjCLjKOMHBFtIRC8gBlGhywJQmQkzDljAgG5\nBAIhEpEOhAidABIXJN3P+ePdLZWyq7u6unZXV9Xvs9a7Ur3fy/O+neqndu13v3srIjAzs9Y2ptEn\nYGZm+TnZm5m1ASd7M7M24GRvZtYGnOzNzNqAk72ZWRtwsjczawNO9mZmbcDJ3sysDYxr9AkMwI/2\ntqjpSxY1JO7Bl7884jEfPWfiiMcE6LijMX8+2/cd25C4933j0xruMXo3H1T1L23M69cPO95Ic83e\nzKwNjOaavZnZiOmlt+ptm7GW7GRvZgbsiJ6qt23GxNmM52xmVndDqdk3Iyd7MzOgp8WHe3eyN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1paNgmlkFTvY22m2MiPvT63uB6X0rRnIUTLNmN27wTcwa\n6pWS1z3AHrDLKJjHhcf8MBv07N63AAAAXklEQVSUk701nZJRMP8idh0F08wqcDOONaOvUcxjuiJN\nkP2NRp+Q2WjnUS/NzNqAa/ZmZm3Ayd7MrA042ZuZtQEnezOzNuBkb2bWBpzszczagJO9mVkbcLI3\nM2sD/x+dw+dKjx9GOwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f15b0697cc0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "import seaborn as sns\n",
    "\n",
    "\n",
    "sns.heatmap(hm[::-1], cmap='viridis')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We see that, on average, we obtain the highest result using trend-determining parameters `n1=40` and `n2=60`,\n",
    "and it's not like other nearby combinations work similarly well — in our particular strategy, this combination really stands out.\n",
    "\n",
    "Since our strategy contains several parameters, we might be interested in other relationships between their values.\n",
    "We can use\n",
    "[`backtesting.lib.plot_heatmaps()`](https://kernc.github.io/backtesting.py/doc/backtesting/lib.html#backtesting.lib.plot_heatmaps)\n",
    "function to plot interactive heatmaps of all parameter combinations simultaneously."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"9ad8e5ea-30a2-48f7-aa35-7df7e3ebd284\" data-root-id=\"2574\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"3ee126f6-e257-47a0-9601-eeb8068935c6\":{\"roots\":{\"references\":[{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"2360\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"2310\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"below\":[{\"id\":\"2416\",\"type\":\"CategoricalAxis\"}],\"left\":[{\"id\":\"2420\",\"type\":\"CategoricalAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"2416\",\"type\":\"CategoricalAxis\"},{\"id\":\"2419\",\"type\":\"Grid\"},{\"id\":\"2420\",\"type\":\"CategoricalAxis\"},{\"id\":\"2423\",\"type\":\"Grid\"},{\"id\":\"2428\",\"type\":\"BoxAnnotation\"},{\"id\":\"2439\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"2540\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"2430\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"2408\",\"type\":\"FactorRange\"},\"x_scale\":{\"id\":\"2412\",\"type\":\"CategoricalScale\"},\"y_range\":{\"id\":\"2410\",\"type\":\"FactorRange\"},\"y_scale\":{\"id\":\"2414\",\"type\":\"CategoricalScale\"}},\"id\":\"2407\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"2515\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"height\":{\"units\":\"data\",\"value\":1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_exit\"},\"y\":{\"field\":\"n2\"}},\"id\":\"2370\",\"type\":\"Rect\"},{\"attributes\":{},\"id\":\"2315\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"2333\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2335\",\"type\":\"Rect\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2336\",\"type\":\"Rect\"},\"selection_glyph\":null,\"view\":{\"id\":\"2338\",\"type\":\"CDSView\"}},\"id\":\"2337\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2441\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2451\",\"type\":\"CategoricalTicker\"}},\"id\":\"2453\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"n_exit\",\"@n_exit\"],[\"n1\",\"@n1\"],[\"Value\",\"@_Value{0.[000]}\"]]},\"id\":\"2393\",\"type\":\"HoverTool\"},{\"attributes\":{\"dimension\":1,\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2305\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2319\",\"type\":\"CategoricalTicker\"}},\"id\":\"2321\",\"type\":\"Grid\"},{\"attributes\":{\"axis_label\":\"n_exit\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2512\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2305\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2315\",\"type\":\"CategoricalTicker\"}},\"id\":\"2314\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"2391\",\"type\":\"ResetTool\"},{\"attributes\":{\"dimension\":1,\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2339\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2353\",\"type\":\"CategoricalTicker\"}},\"id\":\"2355\",\"type\":\"Grid\"},{\"attributes\":{\"fill_color\":{\"field\":\"_Value\",\"transform\":{\"id\":\"2304\",\"type\":\"LinearColorMapper\"}},\"height\":{\"units\":\"data\",\"value\":1},\"line_color\":{\"value\":null},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_exit\"},\"y\":{\"field\":\"n1\"}},\"id\":\"2403\",\"type\":\"Rect\"},{\"attributes\":{},\"id\":\"2563\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2373\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2383\",\"type\":\"CategoricalTicker\"}},\"id\":\"2385\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"2414\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"2412\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"children\":[{\"id\":\"2573\",\"type\":\"ToolbarBox\"},{\"id\":\"2571\",\"type\":\"Column\"}]},\"id\":\"2574\",\"type\":\"Column\"},{\"attributes\":{},\"id\":\"2387\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"high\":17492.809291726964,\"low\":7631.182776182925,\"nan_color\":\"white\",\"palette\":[\"#440154\",\"#440255\",\"#440357\",\"#450558\",\"#45065A\",\"#45085B\",\"#46095C\",\"#460B5E\",\"#460C5F\",\"#460E61\",\"#470F62\",\"#471163\",\"#471265\",\"#471466\",\"#471567\",\"#471669\",\"#47186A\",\"#48196B\",\"#481A6C\",\"#481C6E\",\"#481D6F\",\"#481E70\",\"#482071\",\"#482172\",\"#482273\",\"#482374\",\"#472575\",\"#472676\",\"#472777\",\"#472878\",\"#472A79\",\"#472B7A\",\"#472C7B\",\"#462D7C\",\"#462F7C\",\"#46307D\",\"#46317E\",\"#45327F\",\"#45347F\",\"#453580\",\"#453681\",\"#443781\",\"#443982\",\"#433A83\",\"#433B83\",\"#433C84\",\"#423D84\",\"#423E85\",\"#424085\",\"#414186\",\"#414286\",\"#404387\",\"#404487\",\"#3F4587\",\"#3F4788\",\"#3E4888\",\"#3E4989\",\"#3D4A89\",\"#3D4B89\",\"#3D4C89\",\"#3C4D8A\",\"#3C4E8A\",\"#3B508A\",\"#3B518A\",\"#3A528B\",\"#3A538B\",\"#39548B\",\"#39558B\",\"#38568B\",\"#38578C\",\"#37588C\",\"#37598C\",\"#365A8C\",\"#365B8C\",\"#355C8C\",\"#355D8C\",\"#345E8D\",\"#345F8D\",\"#33608D\",\"#33618D\",\"#32628D\",\"#32638D\",\"#31648D\",\"#31658D\",\"#31668D\",\"#30678D\",\"#30688D\",\"#2F698D\",\"#2F6A8D\",\"#2E6B8E\",\"#2E6C8E\",\"#2E6D8E\",\"#2D6E8E\",\"#2D6F8E\",\"#2C708E\",\"#2C718E\",\"#2C728E\",\"#2B738E\",\"#2B748E\",\"#2A758E\",\"#2A768E\",\"#2A778E\",\"#29788E\",\"#29798E\",\"#287A8E\",\"#287A8E\",\"#287B8E\",\"#277C8E\",\"#277D8E\",\"#277E8E\",\"#267F8E\",\"#26808E\",\"#26818E\",\"#25828E\",\"#25838D\",\"#24848D\",\"#24858D\",\"#24868D\",\"#23878D\",\"#23888D\",\"#23898D\",\"#22898D\",\"#228A8D\",\"#228B8D\",\"#218C8D\",\"#218D8C\",\"#218E8C\",\"#208F8C\",\"#20908C\",\"#20918C\",\"#1F928C\",\"#1F938B\",\"#1F948B\",\"#1F958B\",\"#1F968B\",\"#1E978A\",\"#1E988A\",\"#1E998A\",\"#1E998A\",\"#1E9A89\",\"#1E9B89\",\"#1E9C89\",\"#1E9D88\",\"#1E9E88\",\"#1E9F88\",\"#1EA087\",\"#1FA187\",\"#1FA286\",\"#1FA386\",\"#20A485\",\"#20A585\",\"#21A685\",\"#21A784\",\"#22A784\",\"#23A883\",\"#23A982\",\"#24AA82\",\"#25AB81\",\"#26AC81\",\"#27AD80\",\"#28AE7F\",\"#29AF7F\",\"#2AB07E\",\"#2BB17D\",\"#2CB17D\",\"#2EB27C\",\"#2FB37B\",\"#30B47A\",\"#32B57A\",\"#33B679\",\"#35B778\",\"#36B877\",\"#38B976\",\"#39B976\",\"#3BBA75\",\"#3DBB74\",\"#3EBC73\",\"#40BD72\",\"#42BE71\",\"#44BE70\",\"#45BF6F\",\"#47C06E\",\"#49C16D\",\"#4BC26C\",\"#4DC26B\",\"#4FC369\",\"#51C468\",\"#53C567\",\"#55C666\",\"#57C665\",\"#59C764\",\"#5BC862\",\"#5EC961\",\"#60C960\",\"#62CA5F\",\"#64CB5D\",\"#67CC5C\",\"#69CC5B\",\"#6BCD59\",\"#6DCE58\",\"#70CE56\",\"#72CF55\",\"#74D054\",\"#77D052\",\"#79D151\",\"#7CD24F\",\"#7ED24E\",\"#81D34C\",\"#83D34B\",\"#86D449\",\"#88D547\",\"#8BD546\",\"#8DD644\",\"#90D643\",\"#92D741\",\"#95D73F\",\"#97D83E\",\"#9AD83C\",\"#9DD93A\",\"#9FD938\",\"#A2DA37\",\"#A5DA35\",\"#A7DB33\",\"#AADB32\",\"#ADDC30\",\"#AFDC2E\",\"#B2DD2C\",\"#B5DD2B\",\"#B7DD29\",\"#BADE27\",\"#BDDE26\",\"#BFDF24\",\"#C2DF22\",\"#C5DF21\",\"#C7E01F\",\"#CAE01E\",\"#CDE01D\",\"#CFE11C\",\"#D2E11B\",\"#D4E11A\",\"#D7E219\",\"#DAE218\",\"#DCE218\",\"#DFE318\",\"#E1E318\",\"#E4E318\",\"#E7E419\",\"#E9E419\",\"#ECE41A\",\"#EEE51B\",\"#F1E51C\",\"#F3E51E\",\"#F6E61F\",\"#F8E621\",\"#FAE622\",\"#FDE724\"]},\"id\":\"2304\",\"type\":\"LinearColorMapper\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"2394\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"callback\":null,\"data\":{\"_Value\":{\"__ndarray__\":\"9SzrDGITwUDRU1fHudLGQK58iBglksNANSHTL59Vx0DdvbQDUV3MQJS9WRoKGsJAVKe1QI5Kw0DZiuhU0m3IQAySOYEFGcZAeqs6zrYExUDuhEDz4VbDQNd8yG6eg8VAG1J3kfB+xUCpp+Bo/d/JQP5MVHNZSsFAYzq3Q1MCx0BNBdkLEoLFQEWYJwIZYMJAbNK+r2nSw0BZecYDjdPFQM/vepAGEMlAVUZ5ZJhbyECZrej2RfrFQP5Gpc9HTMdAXBOOk0KnwkA2J6N8FjLDQDCD5oX1+MNATnyyvRT0xUA/LNU7OFnHQCSglGLIqcdAR4uX+qllxUBv4YgnLaHCQF3mHU81k8NAXOG93JorxUAo/zgIwQPFQCDCyE8+EMRAXnZWjIT/w0Bc012vmWLCQCeg5OdFIspAa0bciFnAyECFv68Pw6PIQFtr71Dku8ZAIJxxeXswxkC+Aj7KYjPGQO5dganrs8VAoFSF16nRxUAmkrK/vNTGQCCQgfB1e8JASYrUb7CUxUAsRtmLJxrFQNgF6pavD8VAHdLQQTGIxEAiH6v5KnrDQGtcj3gv+8NArVNWNMagxEC7bX5sQbfDQIS5unKQhMNAY5Zlj7uzxECjXIHUabfDQFKmtNPaBMNAXADfc8rawkAL9m6altnAQGAsOlxWrMJANX1WZkIJxEDppHdHa6LEQA==\",\"dtype\":\"float64\",\"shape\":[65]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64],\"n1\":[\"20\",\"30\",\"20\",\"30\",\"40\",\"50\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\"],\"n2\":[\"40\",\"40\",\"60\",\"60\",\"60\",\"60\",\"80\",\"80\",\"80\",\"80\",\"80\",\"80\",\"100\",\"100\",\"100\",\"100\",\"100\",\"100\",\"100\",\"100\",\"120\",\"120\",\"120\",\"120\",\"120\",\"120\",\"120\",\"120\",\"120\",\"140\",\"140\",\"140\",\"140\",\"140\",\"140\",\"140\",\"140\",\"140\",\"160\",\"160\",\"160\",\"160\",\"160\",\"160\",\"160\",\"160\",\"160\",\"180\",\"180\",\"180\",\"180\",\"180\",\"180\",\"180\",\"180\",\"180\",\"200\",\"200\",\"200\",\"200\",\"200\",\"200\",\"200\",\"200\",\"200\"]},\"selected\":{\"id\":\"2567\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"2566\",\"type\":\"UnionRenderers\"}},\"id\":\"2503\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"2378\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"2550\",\"type\":\"Title\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2458\",\"type\":\"BoxZoomTool\"},{\"id\":\"2459\",\"type\":\"ResetTool\"},{\"id\":\"2460\",\"type\":\"SaveTool\"},{\"id\":\"2461\",\"type\":\"HoverTool\"}]},\"id\":\"2464\",\"type\":\"Toolbar\"},{\"attributes\":{\"toolbar\":{\"id\":\"2572\",\"type\":\"ProxyToolbar\"},\"toolbar_location\":\"above\"},\"id\":\"2573\",\"type\":\"ToolbarBox\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"n2\",\"@n2\"],[\"n1\",\"@n1\"],[\"Value\",\"@_Value{0.[000]}\"]]},\"id\":\"2495\",\"type\":\"HoverTool\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"2519\",\"type\":\"Title\"},{\"attributes\":{\"axis_label\":\"n_enter\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2553\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2441\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2451\",\"type\":\"CategoricalTicker\"}},\"id\":\"2450\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2407\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2417\",\"type\":\"CategoricalTicker\"}},\"id\":\"2419\",\"type\":\"Grid\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2424\",\"type\":\"BoxZoomTool\"},{\"id\":\"2425\",\"type\":\"ResetTool\"},{\"id\":\"2426\",\"type\":\"SaveTool\"},{\"id\":\"2427\",\"type\":\"HoverTool\"}]},\"id\":\"2430\",\"type\":\"Toolbar\"},{\"attributes\":{\"overlay\":{\"id\":\"2326\",\"type\":\"BoxAnnotation\"}},\"id\":\"2322\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2492\",\"type\":\"BoxZoomTool\"},{\"id\":\"2493\",\"type\":\"ResetTool\"},{\"id\":\"2494\",\"type\":\"SaveTool\"},{\"id\":\"2495\",\"type\":\"HoverTool\"}]},\"id\":\"2498\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"2448\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"2428\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"dimension\":1,\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2475\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2489\",\"type\":\"CategoricalTicker\"}},\"id\":\"2491\",\"type\":\"Grid\"},{\"attributes\":{\"axis_label\":\"n1\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2534\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2373\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2387\",\"type\":\"CategoricalTicker\"}},\"id\":\"2386\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"2485\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"dimension\":1,\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2441\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2455\",\"type\":\"CategoricalTicker\"}},\"id\":\"2457\",\"type\":\"Grid\"},{\"attributes\":{\"axis_label\":\"n1\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2555\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2441\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2455\",\"type\":\"CategoricalTicker\"}},\"id\":\"2454\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"n_enter\",\"@n_enter\"],[\"n1\",\"@n1\"],[\"Value\",\"@_Value{0.[000]}\"]]},\"id\":\"2461\",\"type\":\"HoverTool\"},{\"attributes\":{\"overlay\":{\"id\":\"2496\",\"type\":\"BoxAnnotation\"}},\"id\":\"2492\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"2367\",\"type\":\"ColumnDataSource\"}},\"id\":\"2372\",\"type\":\"CDSView\"},{\"attributes\":{\"children\":[{\"id\":\"2539\",\"type\":\"Row\"},{\"id\":\"2570\",\"type\":\"Row\"}]},\"id\":\"2571\",\"type\":\"Column\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"height\":{\"units\":\"data\",\"value\":1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_enter\"},\"y\":{\"field\":\"n1\"}},\"id\":\"2472\",\"type\":\"Rect\"},{\"attributes\":{\"callback\":null,\"data\":{\"_Value\":{\"__ndarray__\":\"URYyBkTzwkDcHjy0MjzFQB+RRGUhncZA5znxeYW9y0AFcA70AynNQGKbisWnj8pAfrbJUEnLzEDEuPRCf4jFQByDmI5Z8cNA1R2NrV3jxUDVjr9J9jTKQE8HiVk76chA/nOjehrYy0Dkdwy0mhrNQEOKEev6fsxAD4dvyzMV0UCTfu0YwyvKQAybEGkg/chAhT4oG9McyEDakVvwvDbKQDeF/D0yVMdAg47eTBxrwkDS07iumc3BQCeAa8ouz71AI4ZAQkM7wUCShL6JomrCQLVL5YHCjMBA9fDji3qcwED8xXfU7SS/QBvudEWwhb5A2LzG/P27wEDCGVYP85zAQIbmM78fBMJAaleRkZfmwUBQcqy0Hq7BQA==\",\"dtype\":\"float64\",\"shape\":[35]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],\"n2\":[\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\",\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\",\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\"],\"n_enter\":[\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"25\",\"25\",\"25\",\"25\",\"25\",\"25\",\"25\",\"25\",\"25\",\"30\",\"30\",\"30\",\"30\",\"30\",\"30\",\"30\",\"30\"]},\"selected\":{\"id\":\"2547\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"2546\",\"type\":\"UnionRenderers\"}},\"id\":\"2435\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis_label\":\"n2\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2545\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2407\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2421\",\"type\":\"CategoricalTicker\"}},\"id\":\"2420\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"callback\":null,\"data\":{\"_Value\":{\"__ndarray__\":\"hRiU1oJIxEBnuciYQ+vEQDJuMf7ls8JA2xh345NYxECxI5RrLi3GQGfdAo/PKsRAOR5hhq/3xkDktPn5DNzDQPlpWpkFncJAfPIkvtmPy0CCK2EWe9bKQHANmJvi9MdA1ZXHOrJyx0CGqJnFfsvGQBjnW7fb+sRAHJOLIQVuyUCkkNtOU7jHQIdSKZ4Lh8ZA0Nxc4v3BwUD+tejhnGjGQDeI7q1cksdA/nEEN2MLwkBwaU6V/TDCQAOn5VXePsJAEqdxbOeFwkAnXGsHFaDAQN8DEksGNL9A\",\"dtype\":\"float64\",\"shape\":[27]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26],\"n2\":[\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\",\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\",\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\"],\"n_exit\":[\"10\",\"10\",\"10\",\"10\",\"10\",\"10\",\"10\",\"10\",\"10\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\"]},\"selected\":{\"id\":\"2526\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"2525\",\"type\":\"UnionRenderers\"}},\"id\":\"2367\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis_label\":\"n2\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2563\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2475\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2485\",\"type\":\"CategoricalTicker\"}},\"id\":\"2484\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"2349\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"callback\":null,\"data\":{\"_Value\":{\"__ndarray__\":\"FzwXzcokxUDJjRIceuvHQE0ep66WfchA3g8mccCax0CVOvKyC/nJQP+gOdP11slAuxMQlv/gyEAHguzEMp/MQHDyYSihEcxAROWBkeNEykATVpkYNe7LQInB7Rab4sxAtX5234EFzEB+Nt4niAnKQK9yZ+MmoMtACM0c9r3HzUADb4RMmurNQILbU7ifA8VAXZQbmsU0xUBnFtvQcnLDQP5R98w5IcFASI1ZMay+wEAHWCGunXi/QGT0Zg8ncsBAC1/VBQiawEAoSCNDHDHBQLyP9FHwW8BAMcSiOKN+wEDNkYiFGLLAQC+AgTZ0qcFArnXiamBKwUDIaCR79gvBQA==\",\"dtype\":\"float64\",\"shape\":[32]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],\"n1\":[\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\"],\"n_enter\":[\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"25\",\"25\",\"25\",\"25\",\"25\",\"25\",\"25\",\"25\",\"30\",\"30\",\"30\",\"30\",\"30\",\"30\",\"30\"]},\"selected\":{\"id\":\"2557\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"2556\",\"type\":\"UnionRenderers\"}},\"id\":\"2469\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"2526\",\"type\":\"Selection\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"height\":{\"units\":\"data\",\"value\":1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_exit\"},\"y\":{\"field\":\"n_enter\"}},\"id\":\"2336\",\"type\":\"Rect\"},{\"attributes\":{\"callback\":null,\"data\":{\"_Value\":{\"__ndarray__\":\"FzwXzcokxUD/jILlwKLFQGrf1iDBTMRAbb+FDia4w0CmlsJqELjDQEj1qRIfSsNAcYrEUhZJxECnQtabvgLGQIT9rYSXusVAGt0297f1ykDB1e45eV/JQF1QF8Ci0sdA7D8DBbFjxkB5EBzd76DFQKBYq/bu28VAlQQEUkNixkAj3dwWUNvGQKSJHMltrMRAkjA3Ixsdw0BIy4nGTznDQBqwTOQobMJAUzLQMoQYwkAHpUArOM3AQPagTl1AGcFAPc2EdkGuwEA=\",\"dtype\":\"float64\",\"shape\":[25]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],\"n1\":[\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\"],\"n_exit\":[\"10\",\"10\",\"10\",\"10\",\"10\",\"10\",\"10\",\"10\",\"10\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"15\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\",\"20\"]},\"selected\":{\"id\":\"2536\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"2535\",\"type\":\"UnionRenderers\"}},\"id\":\"2401\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"2401\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2403\",\"type\":\"Rect\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2404\",\"type\":\"Rect\"},\"selection_glyph\":null,\"view\":{\"id\":\"2406\",\"type\":\"CDSView\"}},\"id\":\"2405\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"2392\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"2451\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"axis_label\":\"n2\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2524\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2339\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2353\",\"type\":\"CategoricalTicker\"}},\"id\":\"2352\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"overlay\":{\"id\":\"2394\",\"type\":\"BoxAnnotation\"}},\"id\":\"2390\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"below\":[{\"id\":\"2382\",\"type\":\"CategoricalAxis\"}],\"left\":[{\"id\":\"2386\",\"type\":\"CategoricalAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"2382\",\"type\":\"CategoricalAxis\"},{\"id\":\"2385\",\"type\":\"Grid\"},{\"id\":\"2386\",\"type\":\"CategoricalAxis\"},{\"id\":\"2389\",\"type\":\"Grid\"},{\"id\":\"2394\",\"type\":\"BoxAnnotation\"},{\"id\":\"2405\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"2529\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"2396\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"2374\",\"type\":\"FactorRange\"},\"x_scale\":{\"id\":\"2378\",\"type\":\"CategoricalScale\"},\"y_range\":{\"id\":\"2376\",\"type\":\"FactorRange\"},\"y_scale\":{\"id\":\"2380\",\"type\":\"CategoricalScale\"}},\"id\":\"2373\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"2421\",\"type\":\"CategoricalTicker\"},{\"attributes\":{},\"id\":\"2565\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"fill_color\":{\"field\":\"_Value\",\"transform\":{\"id\":\"2304\",\"type\":\"LinearColorMapper\"}},\"height\":{\"units\":\"data\",\"value\":1},\"line_color\":{\"value\":null},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n2\"},\"y\":{\"field\":\"n1\"}},\"id\":\"2505\",\"type\":\"Rect\"},{\"attributes\":{\"source\":{\"id\":\"2435\",\"type\":\"ColumnDataSource\"}},\"id\":\"2440\",\"type\":\"CDSView\"},{\"attributes\":{\"callback\":null,\"factors\":[\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\"]},\"id\":\"2478\",\"type\":\"FactorRange\"},{\"attributes\":{},\"id\":\"2494\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"2525\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"2536\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"2567\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"2512\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"callback\":null,\"factors\":[\"15\",\"20\",\"25\",\"30\"]},\"id\":\"2308\",\"type\":\"FactorRange\"},{\"attributes\":{\"callback\":null,\"factors\":[\"10\",\"15\",\"20\"]},\"id\":\"2340\",\"type\":\"FactorRange\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"2560\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"2566\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"callback\":null,\"factors\":[\"10\",\"15\",\"20\"]},\"id\":\"2374\",\"type\":\"FactorRange\"},{\"attributes\":{\"axis_label\":\"n1\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2565\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2475\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2489\",\"type\":\"CategoricalTicker\"}},\"id\":\"2488\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"2529\",\"type\":\"Title\"},{\"attributes\":{\"children\":[{\"id\":\"2407\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"2441\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"2475\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"2570\",\"type\":\"Row\"},{\"attributes\":{},\"id\":\"2319\",\"type\":\"CategoricalTicker\"},{\"attributes\":{},\"id\":\"2480\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"2514\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"data_source\":{\"id\":\"2503\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2505\",\"type\":\"Rect\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2506\",\"type\":\"Rect\"},\"selection_glyph\":null,\"view\":{\"id\":\"2508\",\"type\":\"CDSView\"}},\"id\":\"2507\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"2553\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{},\"id\":\"2489\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"fill_color\":{\"field\":\"_Value\",\"transform\":{\"id\":\"2304\",\"type\":\"LinearColorMapper\"}},\"height\":{\"units\":\"data\",\"value\":1},\"line_color\":{\"value\":null},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_enter\"},\"y\":{\"field\":\"n2\"}},\"id\":\"2437\",\"type\":\"Rect\"},{\"attributes\":{},\"id\":\"2346\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"2425\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"2324\",\"type\":\"SaveTool\"},{\"attributes\":{\"overlay\":{\"id\":\"2360\",\"type\":\"BoxAnnotation\"}},\"id\":\"2356\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2356\",\"type\":\"BoxZoomTool\"},{\"id\":\"2357\",\"type\":\"ResetTool\"},{\"id\":\"2358\",\"type\":\"SaveTool\"},{\"id\":\"2359\",\"type\":\"HoverTool\"}]},\"id\":\"2362\",\"type\":\"Toolbar\"},{\"attributes\":{\"data_source\":{\"id\":\"2367\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2369\",\"type\":\"Rect\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2370\",\"type\":\"Rect\"},\"selection_glyph\":null,\"view\":{\"id\":\"2372\",\"type\":\"CDSView\"}},\"id\":\"2371\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"n_exit\",\"@n_exit\"],[\"n_enter\",\"@n_enter\"],[\"Value\",\"@_Value{0.[000]}\"]]},\"id\":\"2325\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"2516\",\"type\":\"Selection\"},{\"attributes\":{\"below\":[{\"id\":\"2348\",\"type\":\"CategoricalAxis\"}],\"left\":[{\"id\":\"2352\",\"type\":\"CategoricalAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"2348\",\"type\":\"CategoricalAxis\"},{\"id\":\"2351\",\"type\":\"Grid\"},{\"id\":\"2352\",\"type\":\"CategoricalAxis\"},{\"id\":\"2355\",\"type\":\"Grid\"},{\"id\":\"2360\",\"type\":\"BoxAnnotation\"},{\"id\":\"2371\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"2519\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"2362\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"2340\",\"type\":\"FactorRange\"},\"x_scale\":{\"id\":\"2344\",\"type\":\"CategoricalScale\"},\"y_range\":{\"id\":\"2342\",\"type\":\"FactorRange\"},\"y_scale\":{\"id\":\"2346\",\"type\":\"CategoricalScale\"}},\"id\":\"2339\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"2522\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"callback\":null,\"factors\":[\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\"]},\"id\":\"2342\",\"type\":\"FactorRange\"},{\"attributes\":{},\"id\":\"2545\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"axis_label\":\"n_enter\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2543\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2407\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2417\",\"type\":\"CategoricalTicker\"}},\"id\":\"2416\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"axis_label\":\"n_exit\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2522\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2339\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2349\",\"type\":\"CategoricalTicker\"}},\"id\":\"2348\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"callback\":null,\"data\":{\"_Value\":{\"__ndarray__\":\"R7j7iCHWyEAfzuI+5wrIQMcEu3kZyL5AXltos8Z5wED1R9sN0crPQEaHypI6zMNAHyD1Tz7iwUAbCshPJdzDQKZyW5vfbcBA\",\"dtype\":\"float64\",\"shape\":[9]},\"index\":[0,1,2,3,4,5,6,7,8],\"n_enter\":[\"15\",\"20\",\"25\",\"30\",\"20\",\"25\",\"30\",\"25\",\"30\"],\"n_exit\":[\"10\",\"10\",\"10\",\"10\",\"15\",\"15\",\"15\",\"20\",\"20\"]},\"selected\":{\"id\":\"2516\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"2515\",\"type\":\"UnionRenderers\"}},\"id\":\"2333\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"below\":[{\"id\":\"2450\",\"type\":\"CategoricalAxis\"}],\"left\":[{\"id\":\"2454\",\"type\":\"CategoricalAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"2450\",\"type\":\"CategoricalAxis\"},{\"id\":\"2453\",\"type\":\"Grid\"},{\"id\":\"2454\",\"type\":\"CategoricalAxis\"},{\"id\":\"2457\",\"type\":\"Grid\"},{\"id\":\"2462\",\"type\":\"BoxAnnotation\"},{\"id\":\"2473\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"2550\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"2464\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"2442\",\"type\":\"FactorRange\"},\"x_scale\":{\"id\":\"2446\",\"type\":\"CategoricalScale\"},\"y_range\":{\"id\":\"2444\",\"type\":\"FactorRange\"},\"y_scale\":{\"id\":\"2448\",\"type\":\"CategoricalScale\"}},\"id\":\"2441\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"2426\",\"type\":\"SaveTool\"},{\"attributes\":{\"callback\":null,\"factors\":[\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\"]},\"id\":\"2410\",\"type\":\"FactorRange\"},{\"attributes\":{\"overlay\":{\"id\":\"2462\",\"type\":\"BoxAnnotation\"}},\"id\":\"2458\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"height\":{\"units\":\"data\",\"value\":1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_exit\"},\"y\":{\"field\":\"n1\"}},\"id\":\"2404\",\"type\":\"Rect\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"2326\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data_source\":{\"id\":\"2435\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2437\",\"type\":\"Rect\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2438\",\"type\":\"Rect\"},\"selection_glyph\":null,\"view\":{\"id\":\"2440\",\"type\":\"CDSView\"}},\"id\":\"2439\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"2446\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"fill_color\":{\"field\":\"_Value\",\"transform\":{\"id\":\"2304\",\"type\":\"LinearColorMapper\"}},\"height\":{\"units\":\"data\",\"value\":1},\"line_color\":{\"value\":null},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_enter\"},\"y\":{\"field\":\"n1\"}},\"id\":\"2471\",\"type\":\"Rect\"},{\"attributes\":{},\"id\":\"2547\",\"type\":\"Selection\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"2540\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"2546\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"fill_color\":{\"field\":\"_Value\",\"transform\":{\"id\":\"2304\",\"type\":\"LinearColorMapper\"}},\"height\":{\"units\":\"data\",\"value\":1},\"line_color\":{\"value\":null},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_exit\"},\"y\":{\"field\":\"n_enter\"}},\"id\":\"2335\",\"type\":\"Rect\"},{\"attributes\":{\"callback\":null,\"factors\":[\"15\",\"20\",\"25\",\"30\"]},\"id\":\"2442\",\"type\":\"FactorRange\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2322\",\"type\":\"BoxZoomTool\"},{\"id\":\"2323\",\"type\":\"ResetTool\"},{\"id\":\"2324\",\"type\":\"SaveTool\"},{\"id\":\"2325\",\"type\":\"HoverTool\"}]},\"id\":\"2328\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"2459\",\"type\":\"ResetTool\"},{\"attributes\":{\"axis_label\":\"n_enter\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2514\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2305\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2319\",\"type\":\"CategoricalTicker\"}},\"id\":\"2318\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"2543\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"fill_color\":{\"field\":\"_Value\",\"transform\":{\"id\":\"2304\",\"type\":\"LinearColorMapper\"}},\"height\":{\"units\":\"data\",\"value\":1},\"line_color\":{\"value\":null},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_exit\"},\"y\":{\"field\":\"n2\"}},\"id\":\"2369\",\"type\":\"Rect\"},{\"attributes\":{\"below\":[{\"id\":\"2314\",\"type\":\"CategoricalAxis\"}],\"left\":[{\"id\":\"2318\",\"type\":\"CategoricalAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"2314\",\"type\":\"CategoricalAxis\"},{\"id\":\"2317\",\"type\":\"Grid\"},{\"id\":\"2318\",\"type\":\"CategoricalAxis\"},{\"id\":\"2321\",\"type\":\"Grid\"},{\"id\":\"2326\",\"type\":\"BoxAnnotation\"},{\"id\":\"2337\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"2509\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"2328\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"2306\",\"type\":\"FactorRange\"},\"x_scale\":{\"id\":\"2310\",\"type\":\"CategoricalScale\"},\"y_range\":{\"id\":\"2308\",\"type\":\"FactorRange\"},\"y_scale\":{\"id\":\"2312\",\"type\":\"CategoricalScale\"}},\"id\":\"2305\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"2482\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"dimension\":1,\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2373\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2387\",\"type\":\"CategoricalTicker\"}},\"id\":\"2389\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"2460\",\"type\":\"SaveTool\"},{\"attributes\":{\"source\":{\"id\":\"2401\",\"type\":\"ColumnDataSource\"}},\"id\":\"2406\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"2344\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"n_enter\",\"@n_enter\"],[\"n2\",\"@n2\"],[\"Value\",\"@_Value{0.[000]}\"]]},\"id\":\"2427\",\"type\":\"HoverTool\"},{\"attributes\":{\"callback\":null,\"factors\":[\"40\",\"60\",\"80\",\"100\",\"120\",\"140\",\"160\",\"180\",\"200\"]},\"id\":\"2476\",\"type\":\"FactorRange\"},{\"attributes\":{\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2475\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2485\",\"type\":\"CategoricalTicker\"}},\"id\":\"2487\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"factors\":[\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\"]},\"id\":\"2444\",\"type\":\"FactorRange\"},{\"attributes\":{\"callback\":null,\"factors\":[\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\"]},\"id\":\"2376\",\"type\":\"FactorRange\"},{\"attributes\":{},\"id\":\"2532\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"source\":{\"id\":\"2469\",\"type\":\"ColumnDataSource\"}},\"id\":\"2474\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"2383\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"height\":{\"units\":\"data\",\"value\":1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n_enter\"},\"y\":{\"field\":\"n2\"}},\"id\":\"2438\",\"type\":\"Rect\"},{\"attributes\":{\"overlay\":{\"id\":\"2428\",\"type\":\"BoxAnnotation\"}},\"id\":\"2424\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"2357\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"2555\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"height\":{\"units\":\"data\",\"value\":1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"width\":{\"units\":\"data\",\"value\":1},\"x\":{\"field\":\"n2\"},\"y\":{\"field\":\"n1\"}},\"id\":\"2506\",\"type\":\"Rect\"},{\"attributes\":{},\"id\":\"2535\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"source\":{\"id\":\"2333\",\"type\":\"ColumnDataSource\"}},\"id\":\"2338\",\"type\":\"CDSView\"},{\"attributes\":{\"below\":[{\"id\":\"2484\",\"type\":\"CategoricalAxis\"}],\"left\":[{\"id\":\"2488\",\"type\":\"CategoricalAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"2484\",\"type\":\"CategoricalAxis\"},{\"id\":\"2487\",\"type\":\"Grid\"},{\"id\":\"2488\",\"type\":\"CategoricalAxis\"},{\"id\":\"2491\",\"type\":\"Grid\"},{\"id\":\"2496\",\"type\":\"BoxAnnotation\"},{\"id\":\"2507\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"2560\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"2498\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"2476\",\"type\":\"FactorRange\"},\"x_scale\":{\"id\":\"2480\",\"type\":\"CategoricalScale\"},\"y_range\":{\"id\":\"2478\",\"type\":\"FactorRange\"},\"y_scale\":{\"id\":\"2482\",\"type\":\"CategoricalScale\"}},\"id\":\"2475\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"2493\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"2524\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{},\"id\":\"2534\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"n_exit\",\"@n_exit\"],[\"n2\",\"@n2\"],[\"Value\",\"@_Value{0.[000]}\"]]},\"id\":\"2359\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"2312\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2390\",\"type\":\"BoxZoomTool\"},{\"id\":\"2391\",\"type\":\"ResetTool\"},{\"id\":\"2392\",\"type\":\"SaveTool\"},{\"id\":\"2393\",\"type\":\"HoverTool\"}]},\"id\":\"2396\",\"type\":\"Toolbar\"},{\"attributes\":{\"children\":[{\"id\":\"2305\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"2339\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"2373\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"2539\",\"type\":\"Row\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"2509\",\"type\":\"Title\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"2462\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"2323\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"2556\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"2496\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data_source\":{\"id\":\"2469\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"2471\",\"type\":\"Rect\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2472\",\"type\":\"Rect\"},\"selection_glyph\":null,\"view\":{\"id\":\"2474\",\"type\":\"CDSView\"}},\"id\":\"2473\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2305\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2315\",\"type\":\"CategoricalTicker\"}},\"id\":\"2317\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"2557\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"2455\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"callback\":null,\"factors\":[\"15\",\"20\",\"25\",\"30\"]},\"id\":\"2408\",\"type\":\"FactorRange\"},{\"attributes\":{},\"id\":\"2380\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"dimension\":1,\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2407\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2421\",\"type\":\"CategoricalTicker\"}},\"id\":\"2423\",\"type\":\"Grid\"},{\"attributes\":{\"source\":{\"id\":\"2503\",\"type\":\"ColumnDataSource\"}},\"id\":\"2508\",\"type\":\"CDSView\"},{\"attributes\":{\"grid_line_color\":{\"value\":null},\"plot\":{\"id\":\"2339\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2349\",\"type\":\"CategoricalTicker\"}},\"id\":\"2351\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"factors\":[\"10\",\"15\",\"20\"]},\"id\":\"2306\",\"type\":\"FactorRange\"},{\"attributes\":{\"axis_label\":\"n_exit\",\"axis_line_color\":{\"value\":null},\"formatter\":{\"id\":\"2532\",\"type\":\"CategoricalTickFormatter\"},\"major_label_standoff\":0,\"major_tick_line_color\":{\"value\":null},\"plot\":{\"id\":\"2373\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2383\",\"type\":\"CategoricalTicker\"}},\"id\":\"2382\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"2358\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"2353\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"logo\":null,\"tools\":[{\"id\":\"2322\",\"type\":\"BoxZoomTool\"},{\"id\":\"2323\",\"type\":\"ResetTool\"},{\"id\":\"2324\",\"type\":\"SaveTool\"},{\"id\":\"2325\",\"type\":\"HoverTool\"},{\"id\":\"2356\",\"type\":\"BoxZoomTool\"},{\"id\":\"2357\",\"type\":\"ResetTool\"},{\"id\":\"2358\",\"type\":\"SaveTool\"},{\"id\":\"2359\",\"type\":\"HoverTool\"},{\"id\":\"2390\",\"type\":\"BoxZoomTool\"},{\"id\":\"2391\",\"type\":\"ResetTool\"},{\"id\":\"2392\",\"type\":\"SaveTool\"},{\"id\":\"2393\",\"type\":\"HoverTool\"},{\"id\":\"2424\",\"type\":\"BoxZoomTool\"},{\"id\":\"2425\",\"type\":\"ResetTool\"},{\"id\":\"2426\",\"type\":\"SaveTool\"},{\"id\":\"2427\",\"type\":\"HoverTool\"},{\"id\":\"2458\",\"type\":\"BoxZoomTool\"},{\"id\":\"2459\",\"type\":\"ResetTool\"},{\"id\":\"2460\",\"type\":\"SaveTool\"},{\"id\":\"2461\",\"type\":\"HoverTool\"},{\"id\":\"2492\",\"type\":\"BoxZoomTool\"},{\"id\":\"2493\",\"type\":\"ResetTool\"},{\"id\":\"2494\",\"type\":\"SaveTool\"},{\"id\":\"2495\",\"type\":\"HoverTool\"}]},\"id\":\"2572\",\"type\":\"ProxyToolbar\"},{\"attributes\":{},\"id\":\"2417\",\"type\":\"CategoricalTicker\"}],\"root_ids\":[\"2574\"]},\"title\":\"Bokeh Application\",\"version\":\"1.0.3\"}};\n",
       "  var render_items = [{\"docid\":\"3ee126f6-e257-47a0-9601-eeb8068935c6\",\"roots\":{\"2574\":\"9ad8e5ea-30a2-48f7-aa35-7df7e3ebd284\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "2574"
      }
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display: table;\"><div style=\"display: table-row;\"><div style=\"display: table-cell;\"><b title=\"bokeh.models.layouts.Column\">Column</b>(</div><div style=\"display: table-cell;\">id&nbsp;=&nbsp;'2574', <span id=\"2954\" style=\"cursor: pointer;\">&hellip;)</span></div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">children&nbsp;=&nbsp;[ToolbarBox(id='2573', ...), Column(id='2571', ...)],</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">css_classes&nbsp;=&nbsp;[],</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">disabled&nbsp;=&nbsp;False,</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">height&nbsp;=&nbsp;None,</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">js_event_callbacks&nbsp;=&nbsp;{},</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">js_property_callbacks&nbsp;=&nbsp;{},</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">name&nbsp;=&nbsp;None,</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">sizing_mode&nbsp;=&nbsp;'fixed',</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">subscribed_events&nbsp;=&nbsp;[],</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">tags&nbsp;=&nbsp;[],</div></div><div class=\"2953\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">width&nbsp;=&nbsp;None)</div></div></div>\n",
       "<script>\n",
       "(function() {\n",
       "  var expanded = false;\n",
       "  var ellipsis = document.getElementById(\"2954\");\n",
       "  ellipsis.addEventListener(\"click\", function() {\n",
       "    var rows = document.getElementsByClassName(\"2953\");\n",
       "    for (var i = 0; i < rows.length; i++) {\n",
       "      var el = rows[i];\n",
       "      el.style.display = expanded ? \"none\" : \"table-row\";\n",
       "    }\n",
       "    ellipsis.innerHTML = expanded ? \"&hellip;)\" : \"&lsaquo;&lsaquo;&lsaquo;\";\n",
       "    expanded = !expanded;\n",
       "  });\n",
       "})();\n",
       "</script>\n"
      ],
      "text/plain": [
       "Column(id='2574', ...)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from backtesting.lib import plot_heatmaps\n",
    "\n",
    "\n",
    "plot_heatmaps(heatmap, agg='mean')"
   ]
  }
 ],
 "metadata": {
  "jupytext_format_version": "1.1",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
